class UserController < ApplicationController
    def index
      render :action => "login"
    end

    def add_user
      @user = User.new(params[:user])
      if request.post? and @user.save
        flash.now[:notice] = "User #{@user.nickname} created"
        @user = User.new
      end
    end

    def login
      session[:user_id] = nil
      if request.post?
        user = User.authenticate(params[:nickname], params[:password])
        if user
          session[:user_id] = user.id
          session[:nickname] = user.nickname
          session[:permission_level] = user.permission_level
          flash[:notice] = "Succesfully Logged In"
          redirect_to(:action => "overview")
        else
          flash[:notice] = "Invalid User/Password Combination"
        end
      end
    end

    def logout
      session[:user_id] = nil
      redirect_to(:action => "index")
      flash[:notice] = "Succesfully Logout"
    end

    def delete_user
    end

    def list_users
    end
end
